import numpy as np
import matplotlib.pyplot as plt
import os
from scipy.integrate import simps

bin_size= 0.2
min_edge = 0.
max_edge = 45.
bin_list = np.arange(min_edge, max_edge, bin_size)

a = np.loadtxt('dist_type1.txt')
b = np.loadtxt('dist_type2.txt')

fig, ax1 = plt.subplots()
left,bottom,width,height = [0.25,0.55,0.3,0.3]
ax2 = fig.add_axes([left,bottom,width,height])

ax1.plot(a[:,0],a[:,1]/1e6)
ax1.plot(b[:,0],b[:,1]/1e6)
#print(simps(a[:,1]/1e6,a[:,0]),simps(b[:,1]/1e6,b[:,0]))
ax1.set_xlim(0,30)
ax1.set_ylim(0,1.5)
ax1.set_xticks([0,10,20,30])
ax1.set_yticks([0.0,0.5,1.0,1.5])
ax1.minorticks_on()
ax1.set_xlabel(r'$\theta$ (degree)',fontsize=20)
ax1.set_ylabel('Rotation angle distribution (a.u.)',fontsize=20)
ax1.legend(['Type1','Type2'],fontsize=20,frameon=False,loc='lower right')
ax1.tick_params(which='both',direction='in',labelsize=20)




plt.savefig('AngleDistributionFFT.png',format='png',dpi=300,bbox_inches='tight')
plt.show()
